<div>
    <div class="m-subheader">
        <div class="row align-items-center">
            <div class="mr-auto col-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    <span>外包申请</span>
                </h3>
                <span class="m-section__sub">
                    获取审批完成的申请单
                </span>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile" style="margin: 0;">
            <div class="m-portlet__body" style=" overflow: auto;">
                <form class="horizontal-form" autocomplete="off">
                    <div class="m-form m-form--label-align-right">
                        <div class="row align-items-center m--margin-bottom-10">
                            <div class="col-xl-12" style="padding: 0;">
                                <div class="form-group m-form__group align-items-center">
                                    <div class="input-group">
                                        <input [(ngModel)]="filterText" name="filterText" autoFocus class="form-control m-input"
                                            [placeholder]="l('SearchWithThreeDot')" type="text">
                                        <span class="input-group-btn">
                                            <button (click)="getOutsourcingAgreedList()" class="btn btn-primary" type="submit"><i
                                                    class="flaticon-search-1" [attr.aria-label]="l('Search')"></i></button>
                                            <button class="btn btn-success" (click)="exportToexcel()"><i class="far fa-file-excel"></i>导出</button>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row m--margin-bottom-10" [hidden]="!advancedFiltersAreShown">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="DisplayName">开始时间 </label>
                                    <input pInputText type="text" class="form-control m-input" style='width:100%;' name='startDate'
                                        [(ngModel)]="startDate" bsDatepicker>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="DisplayName">结束时间 </label>
                                    <input pInputText type="text" class="form-control m-input" style='width:100%;' name='endDate'
                                        [(ngModel)]="endDate" bsDatepicker>
                                </div>
                            </div>

                        </div>

                        <div class="row margin-bottom-10" *ngIf="advancedFiltersAreShown">
                            <div class="col-sm-12 text-right">
                                <button class="btn btn-metal" (click)="getOutsourcingAgreedList()"><i class="fa fa-sync"></i>刷新</button>
                            </div>
                        </div>
                        <div class="row margin-bottom-10">
                            <div class="col-sm-12">
                                <span class="clickable-item text-muted" *ngIf="!advancedFiltersAreShown" (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i
                                        class="fa fa-angle-down"></i> {{"ShowAdvancedFilters" | localize}}</span>
                                <span class="clickable-item text-muted" *ngIf="advancedFiltersAreShown" (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i
                                        class="fa fa-angle-up"></i> {{"HideAdvancedFilters" | localize}}</span>
                            </div>
                        </div>
                    </div>
                </form>
                <div class="row align-items-center">
                    <!--<Primeng-TurboTable-Start>-->
                    <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
                        <p-table #dataTable (onLazyLoad)="getOutsourcingAgreedList($event)" [value]="primengTableHelper.records"
                            rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false" [lazy]="true"
                            [scrollable]="true" ScrollWidth="100%" [responsive]="primengTableHelper.isResponsive"
                            [resizableColumns]="primengTableHelper.resizableColumns">
                            <ng-template pTemplate="header">
                                <tr>
                                    <th style="width: 50px">
                                        序号
                                    </th>
                                    <th style="width: 200px">
                                        申请单编号
                                    </th>
                                    <th style="width: 150px">
                                        申请单位
                                    </th>
                                    <th style="width: 150px">
                                        申请人
                                    </th>
                                    <th style="width: 150px">
                                        技术质量协议编号
                                    </th>
                                    <th style="width: 150px">
                                        任务编号
                                    </th>
                                    <th style="width: 150px">
                                        产品图号
                                    </th>
                                    <th style="width: 150px">
                                        产品名称
                                    </th>
                                    <th style="width: 150px">
                                        选定供方
                                    </th>
                                    <th style="width: 150px">
                                        加工状态
                                    </th>
                                    <th style="width: 80px">
                                        申请数量
                                    </th>
                                    <th style="width: 80px">
                                        加工数量
                                    </th>
                                    <th style="width: 80px">
                                        交货数量
                                    </th>
                                    <th style="width: 200px">
                                        申请时间
                                    </th>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="body" let-record="$implicit" let-ri="rowIndex">
                                <tr>
                                    <td style="width: 50px;text-align:center;">
                                        <!-- <div class="btn-group dropdown" dropdown container="body">
                                            <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                                                <i class="fa fa-cog"></i><span class="caret"></span>
                                                操作
                                            </button>
                                            <ul class="dropdown-menu" *dropdownMenu>
                                                <li>
                                                    <a href="javascript:;" (click)="OpenProcesingList(record.code)">外包加工单</a>
                                                </li>
                                                <li>
                                                    <a href="javascript:;" (click)="OpenOutsourcingApplyChangeList(record.code,record.outsourcingType)">变更单</a>
                                                </li>
                                                <li>
                                                    <a href="javascript:;">历史记录</a>
                                                </li>
                                            </ul>
                                        </div> -->
                                        {{ri+1}}
                                    </td>
                                    <td style="width: 200px">
                                        <h5><a href="javascript:;" title="点击查看申请单" (click)="Detail(record)">
                                                {{record.code}} </a></h5>
                                        <span *ngIf="record.outsourcingType==0" class="label m-badge m-badge--success m-badge--wide"
                                            data-toggle="tooltip" title="外包项目类型" data-placement="top">
                                            一般过程外包项目
                                        </span>
                                        <span *ngIf="record.outsourcingType==1" class="label m-badge m-badge--primary m-badge--wide"
                                            data-toggle="tooltip" title="外包项目类型" data-placement="top">
                                            关键过程外包项目
                                        </span>
                                        <span *ngIf="record.applyStatus==1" class="label m-badge m-badge--success m-badge--wide"
                                            data-toggle="tooltip" title="申请状态" data-placement="top">
                                            已暂停
                                        </span>
                                        <span *ngIf="record.applyStatus==2" class="label m-badge m-badge--success m-badge--wide"
                                            data-toggle="tooltip" title="申请状态" data-placement="top">
                                            完成
                                        </span>
                                        <span *ngIf="record.applyStatus==0" class="label m-badge m-badge--primary m-badge--wide"
                                            data-toggle="tooltip" title="申请状态" data-placement="top">
                                            运行
                                        </span>
                                        <span *ngIf="record.applyStatus==3" class="label m-badge m-badge--warning m-badge--wide"
                                            data-toggle="tooltip" title="申请状态" data-placement="top">
                                            已终止
                                        </span>
                                    </td>
                                    <td style="width: 150px">
                                        {{record.applyUnit}}
                                    </td>
                                    <td style="width: 150px">
                                        <div [ngSwitch]="record.createdUser">
                                            <div *ngSwitchCase="">
                                                <div class="m-loader m-loader--warning" style="width: 30px; display: inline-block;"></div>
                                            </div>
                                            <div *ngSwitchDefault>
                                                <h6>
                                                    <font style="vertical-align: inherit;">
                                                        <span class="m--font-metal"> <i class="la la-user"></i></span>
                                                        <span class="m--font-bold"> {{record.createdUser}}</span>
                                                    </font><br>
                                                </h6>
                                                <h6>
                                                    <font style="vertical-align: inherit;">
                                                        <span class="m--font-metal"> {{record.createdUserName}} </span>
                                                    </font>
                                                </h6>
                                            </div>
                                        </div>
                                    </td>
                                    <td style="width: 150px">
                                        {{record.technicalQualityAgreementCode}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.taskCode}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.picNo}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.taskName}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.supplierName}}
                                    </td>
                                    <td style="width: 150px">
                                        {{record.workStatus}}
                                    </td>
                                    <td style="width: 80px">
                                        {{record.outsouringAmount}}
                                    </td>
                                    <td style="width: 80px">
                                        <div [ngSwitch]="record.processingAmount">
                                            <div *ngSwitchCase="">
                                                <div class="m-loader m-loader--warning" style="width: 30px; display: inline-block;"></div>
                                            </div>
                                            <div *ngSwitchDefault>
                                                <h6>
                                                    <font style="vertical-align: inherit;">
                                                        <span class="m--font-bold"> {{record.processingAmount}}</span>
                                                    </font><br>
                                                </h6>
                                            </div>
                                        </div>
                                    </td>
                                    <td style="width: 80px">
                                        <div [ngSwitch]="record.deliveryAmount">
                                            <div *ngSwitchCase="">
                                                <div class="m-loader m-loader--warning" style="width: 30px; display: inline-block;"></div>
                                            </div>
                                            <div *ngSwitchDefault>
                                                <h6>
                                                    <font style="vertical-align: inherit;">
                                                        <span class="m--font-bold"> {{record.deliveryAmount}}</span>
                                                    </font><br>
                                                </h6>
                                            </div>
                                        </div>
                                    </td>
                                    <td style="width: 200px">
                                        {{record.creationTime | momentFormat:'L'}}
                                    </td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                            {{'NoData' | localize}}
                        </div>
                        <div class="primeng-paging-container">
                            <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                (onPageChange)="getOutsourcingAgreedList($event)" [totalRecords]="primengTableHelper.totalRecordsCount"
                                [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">

                            </p-paginator>
                            <span class="total-records-count">
                                {{'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount}}
                            </span>
                        </div>
                    </div>
                    <!--<Primeng-TurboTable-End>-->
                </div>
            </div>
        </div>
    </div>

    <flowworkauditdetailmodel #flowworkauditdetailmodel></flowworkauditdetailmodel>
    <processingOrderList #processingOrderList></processingOrderList>
    <flowworkauditmodel #flowworkauditform></flowworkauditmodel>
    <OutsourcingApplyChangeList #OutsourcingApplyChangeList></OutsourcingApplyChangeList>
</div>
